package com.kgo.eidtor.service.impl;

import cn.hutool.core.util.IdUtil;
import com.kgo.eidtor.dao.KgoDocumentsDao;
import com.kgo.eidtor.entity.KgoDocuments;
import com.kgo.eidtor.service.DocumentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author keepgoon
 * @Description: TODO
 * @date 2019/1/2612:04
 */
@Service
public class DocumentServiceImpl implements DocumentService {
    @Resource
    private KgoDocumentsDao documentsDao;


    @Override
    public KgoDocuments getDocument(String documentId) {
        return documentsDao.selectByPrimaryKey(documentId);
    }

    @Override
    public int addDocument(KgoDocuments document) {
        if (StringUtils.isBlank(document.getId())){
            document.setId(IdUtil.simpleUUID());
        }

        return documentsDao.insert(document);
    }
}
